package org.generic.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.generic.interfaces.entity.User;

import javax.validation.constraints.NotBlank;
import java.util.Collection;
import java.util.Date;

/**
 * 系统优化实体类
 *
 * @author LiKun
 * @date 2021/11/8 18:50
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@TableName("system_user")
@ApiModel("系统用户实体类")
public class SystemUser implements User {
    @TableId
    @ApiModelProperty(value = "id", notes = "账号ID")
    private String id;

    @ApiModelProperty(value = "enabled", notes = "账号是否可用")
    private boolean enabled;

    @NotBlank(message = "账号名称不能为空")
    @ApiModelProperty(value = "username", notes = "用户账号名称")
    private String username;

    @NotBlank(message = "账号密码不能为空")
    @ApiModelProperty(value = "password", notes = "用户账号密码")
    private String password;

    @TableField(exist = false)
    @ApiModelProperty(value = "systemRoles", notes = "用户权限信息")
    private Collection<SystemRole> authorities;

    @TableField(exist = false)
    @JsonFormat(pattern = "yyyy-MM-dd kk:mm:ss", timezone = "GMT+8")
    @ApiModelProperty(value = "loginTime", notes = "用户登陆时间")
    private Date loginTime;

    @TableField(exist = false)
    @JsonFormat(pattern = "yyyy-MM-dd kk:mm:ss", timezone = "GMT+8")
    @ApiModelProperty(value = "lastAccess", notes = "用户上次请求")
    private Date lastAccess;

    @TableField(exist = false)
    @ApiModelProperty(value = "remoteAddress", notes = "用户请求IP地址")
    private String remoteAddress;

    @TableField(exist = false)
    @ApiModelProperty(value = "lastAccessPath", notes = "用户上次请求路径")
    private String lastAccessPath;
}
